package com.crm.service.system.job.controller.v1;

import com.crm.model.common.dtos.PageResponseResult;
import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.system.job.dtos.JobFormDto;
import com.crm.model.system.job.dtos.JobDto;
import com.crm.model.system.job.pojos.Job;
import com.crm.service.system.job.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/job")
public class JobController {
    @Autowired
    private JobService jobService;

    /**
     * 分页查询
     * @param jobDto
     * @return
     */
    @GetMapping("/list")
    public PageResponseResult findPage(JobDto jobDto){
        return jobService.findPage(jobDto);
    }

    /**
     * 添加岗位
     * @param jobFormDto
     * @return
     */
    @PostMapping("/add")
    public ResponseResult<String> addJob(@RequestBody JobFormDto jobFormDto){
        return jobService.add(jobFormDto);
    }

    /**
     * 删除岗位
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public ResponseResult<String> deleteJob(@PathVariable Integer id){
        return jobService.delete(id);
    }

    /**
     * 根据id查询岗位
     * @param id
     * @return
     */
    @GetMapping("/find/{id}")
    public ResponseResult<Job> findById(@PathVariable Integer id){
        return jobService.findById(id);
    }

    /**
     * 修改岗位信息
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public ResponseResult<String> update(@RequestBody JobFormDto dto){
        return jobService.update(dto);
    }

}
